@layout("/common/_container.html",{title:"绑定卡号",js:["/assets/modular/recy/wechatUser/wechatUser.js","/assets/common/libs/rapid-validator/prototype_for_validation.js","/assets/common/libs/rapid-validator/validation_cn.js","/assets/common/libs/rapid-validator/tooltips.js"]}){
<style>
    .round_icon{
        width: 132px;
        height: 132px;
        display: flex;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
</style>
<div style="position:relative;">
    @if(!isEmpty(user.cardNo)){
    <div style="line-height:2;text-align:center">已绑定卡号：${user.cardNo}</div>
    @}else{
    <form action="${ctxPath}/app/bindCardNo" class="layui-form">
        <input type="hidden" name="userId" value="${user.id}">
        <div class='layui-form-item'>
            <div class="layui-inline">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input style="width:150px" id="name" name="cardNo" placeholder="请输入姓名" type="text" class="layui-input   " />
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input style="width:150px" id="phone" name="cardNo" placeholder="请输入手机号" type="text" class="layui-input   " />
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">卡号</label>
                <div class="layui-input-block">
                    <input style="width:150px" id="cardNo" name="cardNo" placeholder="请输入卡号" type="text" class="layui-input   " />
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-block">
                    <input type="submit" class="layui-btn" value="绑定">
                </div>
            </div>
        </div>
    </form>
    @}
</div>
@}
<script>
    layui.use(["form","jquery"],function(){
        var $=layui.jquery;
        var form = layui.form;
        form.on("submit",function(data){
           var cardNo = $("#cardNo").val();
           if($.trim(cardNo)==""){
               Feng.error("卡号不能为空！");
               return false;
           }
           var name=$("#name").val();
           if($.trim(name)==""){
               Feng.error("姓名不能为空！");
               return false;
           }
           var phone=$("#phone").val();
           if($.trim(phone)=="" && !/^\d{11}$/.test(phone)){
               Feng.error("手机号必须是11位数字");
               return false;
           }
            var ajax = new $ax(Feng.ctxPath + "/app/bindCardNo", function (data) {
                Feng.success("绑定成功！");
            }, function (data) {
                Feng.error("添加失败！" + data.responseJSON.message)
            });
            ajax.set("userId",$("#userId").val());
            ajax.set("cardNo",$("#cardNo").val());
            ajax.start();
           return false;
        });
    })
</script>